using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Auto.Data.DBUtility;

namespace BaseSystem
{
    public class Menu
    {
        //private static string connectionString = "Provider=Microsoft.jet.OLEDB.4.0;data Source="
        //    + HttpContext.Current.Server.MapPath(@"App_Data\MenuDB.mdb");

        //private DataTable ExecuteQuery(string cmdText)
        //{
        //    using (OleDbConnection conn = new OleDbConnection(connectionString))
        //    {
        //        using (OleDbDataAdapter oda = new OleDbDataAdapter(cmdText, conn))
        //        {
        //            DataSet ds = new DataSet();
        //            oda.Fill(ds);
        //            return ds.Tables[0];
        //        }
        //    }
        //}

       /// <summary>
       /// Get the Top top Menu OF System
       /// </summary>
       /// <param name="SysID">System ID</param>
       /// <returns></returns>
        public DataTable GetMenu(string SysID)
        {
            string sql = "select  * from _SysFunctions where ParentID IS NULL AND SysID='"+SysID+"'";
            return DbHelper.ExecuteQuery(sql).Tables[0];
        }

        /// <summary>
        /// Get Sub Functions
        /// </summary>
        /// <param name="SysID">SysID</param>
        /// <param name="FuncID">Function ID</param>
        /// <returns></returns>
        public DataTable GetMenuBySupCode(string SysID,string FuncID)
        {
            string sql = "select  * from _SysFunctions where SysID='"+SysID+"' AND ParentID='" + FuncID + "'";
            return DbHelper.ExecuteQuery(sql).Tables[0];
        }

        public DataTable GetModule()
        {
            string sql = "select distinct SysID from MENU";
            return DbHelper.ExecuteQuery(sql).Tables[0];
        }
    }
}
